<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
	<style>
		#box{
			width: 200px;
			height: 200px;
			background-color: #000;
			border-radius: 50%;
		}
	</style>
</head>
<body>
	<button id="btn">开灯</button>
	<div id="box"></div>
</body>
<script>
	var btn =document.getElementById('btn');
	var box =document.getElementById('box');
	var flag = 0;
	btn.onclick = function(){
		if(flag == 0){
			box.style.backgroundColor = "yellow";
			btn.innerHTML = '关灯';
			flag = 1;
		}else{
			box.style.backgroundColor = "#000";
			btn.innerHTML = '开灯';
			flag = 0;
		}
		
	}
		
	
	
	
	
	
	
</script>
</html>